const baseUrl = 'https://volunteer.onecube.top/file/upload';

function main(file, body, header) {
  return new Promise((resolve, reject) => {
    wx.uploadFile({
      filePath: file,
      name: 'image',
      url: baseUrl,
      header,
      formData: body,
      success: res => {
        const data = JSON.parse(res.data);
        return resolve(data);
      }, fail: err => {
        return reject(err);
      }
    });
  });
}

module.exports = main;